package br.com.werp.suporte.Usuario;
import java.util.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;

/**
 * Creation Date 03/09/2004 10:24:52
 * Last Modify Date 23/02/2006 16:10:44
 */

public class EmailDetalheActionForm extends org.apache.struts.action.ActionForm {
  public String emil_id;
  public String emil_endereco;
  private boolean valida = false;
  public EmailDetalheActionForm() {
  }
  /**
    * EMIL_ID: Gets the value of this field.
    */
  public String getEmil_id() {
    return emil_id;
  }
  /**
     * EMIL_ID: Sets thhe value for this field.
     */
  public void setEmil_id(String EMIL_ID) {
    emil_id = EMIL_ID;
  }
  /**
    * EMIL_ENDERECO: Gets the value of this field.
    */
  public String getEmil_endereco() {
    return emil_endereco;
  }
  /**
     * EMIL_ENDERECO: Sets thhe value for this field.
     */
  public void setEmil_endereco(String EMIL_ENDERECO) {
    emil_endereco = EMIL_ENDERECO;
  }
  /**
    * Reset all fields.
    */
  public void reset(org.apache.struts.action.ActionMapping mapping,
      javax.servlet.http.HttpServletRequest request) {
    emil_id = null;
    emil_endereco = null;
  }
  /**
    * Validate fields and return ActionErrors.
    */

  public ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
      javax.servlet.http.HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    valida = false;
    if (!com.egen.util.struts.Token.isTokenValid(mapping, request)) {
      errors.add("Warning", new ActionError("token.error","<br>","","",""));
    }
    com.egen.util.struts.Token.saveToken(mapping, request);
    if (com.egen.util.text.Validate.isValidate("update_action,delete_action,",
        request)) {

      if (com.egen.util.text.Validate.isNull(emil_endereco)) {
        errors.add("ActionErrors.GLOBAL_ERROR",
            new ActionError("error.validate.notnull","e-mail","emil_endereco",
                "0"));
      }
      if (!com.egen.util.text.Validate.isRegex(emil_endereco, "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")) {
        errors.add("ActionErrors.GLOBAL_ERROR",
            new ActionError("error.validate.regex","e-mail","emil_endereco",
                "0"));
      }
    }
    if (errors != null && errors.size() > 0) {
      javax.servlet.http.HttpSession session = request.getSession(true);
      ActionForward actionForward = null;
      session.setAttribute(mapping.getName(), this);
    }
    return errors;
  }
}
